﻿using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using System;



namespace ZingFrameworkCore.Data.EntityFramwork
{
    public static class ServiceCollectionExtensions
    {
        public static IServiceCollection UseDbContext(this IServiceCollection services)
        {
            services.AddDbContextPool<MySqlDbContext>((IServiceProvider sp, DbContextOptionsBuilder options) =>
            {
                options.UseMySql(sp.GetService<IConfiguration>()["DbConnectionString:_MysqlConnectionString"]);
            });
            return services;
        }
    }
}
